﻿using Domain.Factory_Modeling;
using Domain.Material_Management;
using Domain.Production_Modules;
using Infratructure.Interface;
using MediatR;
using MES.Server.API.Application.Command.Production_Modules.Pulldown;
using ReturnValue;

namespace MES.Server.API.Application.Handler.Production_Modules.Pulldown
{
    public class ProductionLineInfoQueryCommandHandler : IRequestHandler<ProductionLineInfoQueryCommand, ApiResult<List<ProductionLineModel>>>
    {
        private readonly IRepository<ProductionLineModel> ProductionLineRepo;
        public ProductionLineInfoQueryCommandHandler(IRepository<ProductionLineModel> ProductionLineRepo)
        {
            this.ProductionLineRepo = ProductionLineRepo;
        }
        public Task<ApiResult<List<ProductionLineModel>>> Handle(ProductionLineInfoQueryCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<ProductionLineModel>> result=new ApiResult<List<ProductionLineModel>>();
            result.Code=StatusCode.Success;
            result.Message=StatusCode.Success.ToString();
            var list=ProductionLineRepo.GetAll();
            result.Data=list.ToList();
            return Task.FromResult(result);
        }

    }
}
